package com.want.api.user;

import com.want.annotation.WantClient;
import com.want.model.dto.Result;
import com.want.req.base.PageReqDto;
import com.want.req.user.dto.LoginReqDto;
import com.want.req.user.dto.RegisterReqDto;
import com.want.req.user.dto.UpdateUserReqDto;
import com.want.resp.base.PageResp;
import com.want.resp.user.dto.*;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import reactor.core.publisher.Mono;

import java.util.List;

/**
 * @author WangZhiJian
 * @since 2021/12/4 0004
 */
@WantClient(value = "userApi",serviceName = "user-service-v1",context = "want-user-service")//,uri = "http://localhost:8081"path = "user",
public interface UserApi {

    @PostMapping("saveUser")
    Mono<Result<RegisterRespDto>> saveUser(@RequestBody RegisterReqDto registerReqDto);

    @GetMapping("findById")
    Mono<Result<UserDto>> findById(Integer id);

    @PostMapping(value = "listUser")
    Mono<Result<PageResp<UserDto>>> listUser(@RequestBody PageReqDto pageReqDto);

    @PostMapping("login")
    Mono<Result<LoginRespDto>> login(@RequestBody @Validated LoginReqDto loginReqDto);

    @GetMapping("userRole/{id}")
    Mono<Result<List<String>>> userRole(@PathVariable("id") Integer uid);

    @GetMapping(value = "listUser/{index}/{size}")
    Mono<Result<PageResp<UserDto>>> listUser(@PathVariable("index") Integer index, @PathVariable("size") Integer size);

    @GetMapping("userInfo")
    Mono<Result<UserInfoDto>> userInfo(Integer id);

    @GetMapping("roleList")
    Mono<Result<List<RoleDto>>> roleList();
    @GetMapping("userRole/delete/{id}")
    public Mono<Result<String>> delete(@PathVariable("id") Integer uid);
    @PostMapping("updateUser")
    public Mono<Result<Integer>> updateUser(@RequestBody UpdateUserReqDto updateUserReqDto);

    @PostMapping("role/add")
    public Mono<Result<RoleDto>> createRole(@RequestBody RoleDto roleDto);

    @GetMapping("role/delete/{id}")
    public Mono<Result<Integer>> deleteRole(@PathVariable("id") Integer id);
}
